<template>
  <div class="detail-box">
    <!-- top -->
    <div class="detail-box-top" v-if="!second">
      <!-- left -->
      <div class="detail-box-top-left">
        <div class="title">
          <slot name="title">{{ title }}</slot>
        </div>
      </div>
      <!-- right -->
      <div class="detail-box-top-right">
        <svg-icon icon-class="close" class="close" @click="close"></svg-icon>
      </div>
    </div>
    <!-- content -->
    <div
      class="detail-box-content"
      :style="{
        flexDirection: direction,
        ...mainStyle
      }"
    >
      <slot></slot>
    </div>
  </div>
</template>

<script>
/**
 * 详情弹框组件
 * @author 朱琦（zhuq@microvideo.cn）
 * @date   时间：2022/10/27
 */
export default {
  name: 'DetailBox',
  props: {
    // 面板标题
    title: {
      type: String,
      default: ''
    },
    align: {
      type: String,
      default: 'left'
    },
    // 内容排列方式
    direction: {
      type: String,
      default: 'column' // column or row
    },
    // 是否是二级的面板样式
    second: {
      type: Boolean,
      default: false
    },
    // 主体样式
    mainStyle: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  components: {},
  data() {
    return {
      active: false
    }
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {
    close() {
      this.$emit('close')
      console.log('close');
    }
  }
}
</script>

<style scoped lang="less">
@import url(../../styles/themes/index.less);
.detail-box {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(233, 240, 253, 0.5);
  border: 1px solid rgba(131, 163, 226, 0.5);
  padding: 5px 10px 10px;

  &-top {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    overflow: hidden;

    &-left {
      display: flex;
      align-items: center;
      overflow: hidden;
      margin-right: 5px;
      z-index: 1;
      .title {
        .subhead();
      }
    }

    &-right {
      flex-shrink: 0;
      z-index: 1;
      .close {
        cursor: pointer;
      }
    }
  }

  &-content {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  // 内容面板的间距
  /deep/.mz-panel {
    margin-right: 10px;
    &:last-child {
      margin: 0;
    }
  }
}
</style>
